package com.vf.admin.client.service.impl;

import com.vf.admin.client.dao.AppMingxiRoomDao;
import com.vf.admin.client.service.AppMingxiRoomService;
import com.vf.admin.miaodong.dao.AfterUserDao;
import com.vf.admin.miaodong.entity.AppMingxiRoom;
import com.vf.admin.miaodong.entity.AppRoom;
import com.vf.admin.miaodong.entity.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 账单明细-金币
 */
@Service
public class AppMingxiRoomServiceImpl implements AppMingxiRoomService {
    @Autowired
    private AppMingxiRoomDao appMingxiRoomDao;
    @Autowired
    private AfterUserDao afterUserDao;

    /**
     * 添加明细
     */
    @Override
    public void addMIngxi(AppUser user, BigDecimal money, Integer moneyleixing, Integer leixing, String beizhu, AppRoom room) {
        AppUser fangzhu=afterUserDao.get(room.getUserid());
        AppMingxiRoom mingxiRoom=new AppMingxiRoom();
        mingxiRoom.setUserid(user.getId());
        mingxiRoom.setPhone(user.getLoginname());
        mingxiRoom.setNick(user.getNick());
        mingxiRoom.setPic(user.getPic());
        mingxiRoom.setNum(money.longValue());
        mingxiRoom.setMoneyleixing(moneyleixing);
        mingxiRoom.setLeixing(leixing);
        mingxiRoom.setBeizhu(beizhu);
        mingxiRoom.setRoomusernike(fangzhu.getNick());
        mingxiRoom.setRoomuserphone(fangzhu.getLoginname());
        mingxiRoom.setRoomuserpic(fangzhu.getPic());
        mingxiRoom.setRoomid(room.getId());
        mingxiRoom.setRoomcode(room.getRoomcode());
        mingxiRoom.setRoomname(room.getRoomname());
        mingxiRoom.setCreatetime(new Date());
        appMingxiRoomDao.save(mingxiRoom);
    }

}
